function qqNotify(){
    text=$1
    curl -X POST http://codecrop.cc:8000/qq/notify -d "content=$text"
}

echo $CLASSPATH
check_user=`whoami`
if [ "$check_user" != "root" ]
then
    echo "请在root用户下执行"
    exit
fi

source ~/.bashrc
source /etc/profile
gitdown=/app/src
projectname=simplebook
jarname=simplebook-1.0-SNAPSHOT.jar
cd ${gitdown}
if [ -d ${gitdown}/${projectname} ]
then
    echo "${gitdown}/mma目录存在！"
    cd ${gitdown}/${projectname}
    git stash
    git pull
    git stash pop
else
    echo "${gitdown}/${projectname} 目录不存在！"
    cd ${gitdown}
    git clone git@gitee.com:jiayen/simplebook.git
fi

cd ${gitdown}/${projectname}
mvn install -DskipTests
mvn clean package -DskipTetst  -U
/bin/cp ${gitdown}/jar/${jarname} ${gitdown}/jar/${jarname}.bak
rm -rf ${gitdown}/jar/${jarname}
mv target/${jarname} ${gitdown}/jar/
ps -aux|grep ${jarname}|grep -v server.port|grep -v grep|awk '{print $2}'|xargs kill -9
nohup java -jar ${gitdown}/jar/${jarname} --spring.profiles.active=dev --server.port=8899> ${gitdown}/jar/${projectname}.log 2>&1 &
echo ------------ok----------------
Branch=`git branch|awk '{print $2}'`
HostName=`hostname`
gitinfo=`git log|sed -n 1,6p`
release_info="$0 is deployed, Branch: $Branch , HostName: $HostName "
echo $release_info`date`
gitinfo=`git log|sed -n 1,6p`
#qqNotify "${gitinfo}  ---------    $release_info"
